//
//  MyCollectionViewCell.m
//  HDYS
//
//  Created by qianfeng on 15-4-23.
//  Copyright (c) 2015年 kay. All rights reserved.
//

#import "MyCollectionViewCell.h"
#import "UIImageView+WebCache.h"

#define SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width

@interface MyCollectionViewCell ()
{
    UIImageView *imgView;
    UILabel *priceLabel;
    UILabel *desLabel;
}
@end

@implementation MyCollectionViewCell

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self createSubViewsWithFrame:(CGRect)frame];
    }
    return self;
}

-(void)createSubViewsWithFrame:(CGRect)frame{
    imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, 220)];
    imgView.image = [UIImage imageNamed:@"guide_s4@3x.jpg"];
    [self addSubview:imgView];
    
    CGFloat priceLabelW = 30;
    desLabel = [[UILabel alloc] initWithFrame:CGRectMake(imgView.frame.origin.x, imgView.frame.origin.y + imgView.frame.size.height + 5, frame.size.width - priceLabelW - 10, 25)];
    desLabel.font = [UIFont systemFontOfSize:9];
    desLabel.numberOfLines = 0;
    [self addSubview:desLabel];
    
    priceLabel = [[UILabel alloc] initWithFrame:CGRectMake(desLabel.frame.origin.x + desLabel.frame.size.width + 10, desLabel.frame.origin.y, priceLabelW, desLabel.frame.size.height)];
    priceLabel.textAlignment = NSTextAlignmentRight;
    priceLabel.font = [UIFont systemFontOfSize:9];
    [self addSubview:priceLabel];
}

- (void)configUIWithModel:(MainDataModel *)model {
    NSString *newStr = [@"http://mls.coderss.cn/Public/Uploads/goods/" stringByAppendingString:model.pic];
    [imgView setImageWithURL:[NSURL URLWithString:newStr]];
    priceLabel.text = model.price;
    desLabel.text = model.gname;
    
}



@end
